<%@ page contentType="text/html;charset=ISO-8859-1" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
	    <link type="text/css" rel="stylesheet" href="/webapp/stylesheet/common.css">
	    <title>DeepStack : Statistics</title>
	  	<script type="text/javascript" language="javascript" src="/webapp/javascript/common.js"></script>
	</head>
  	<body>
  		<h2>Hall of fame</h2>
  		<table border="1">
  			<tr>
  				<th>Rank</th>
  				<th>Player</th>
  				<th>Points</th>	
  			</tr>
  			<c:set scope="page" var="rank" value="0" />
  			<c:forEach var="entry" items="${statistics.hallOfFame}" >
  			<c:set scope="page" var="rank" value="${rank + 1}" />
			<tr>
				<td><c:out value="${rank}"/></td>
				<td><c:out value="${entry.key}"/></td>
				<td><c:out value="${entry.value}"/></td>
			</tr>
			</c:forEach>
			<c:remove var="rank" scope="page"/>	
  		</table>
  		<h2>Informations</h2>
  		<table border="1">
  			<tr>
  				<td>Tournaments</td>
  				<td><c:out value="${statistics.numberOfTournaments}" /></td>
  			</tr>
  			<tr>
  				<td>Players</td>
  				<td><c:out value="${statistics.numberOfPlayers}" /></td>
  			</tr>
  			<tr>
  				<td>Players / tournament</td>
  				<td><c:out value="${statistics.averageNumberOfPlayers}" /></td>
  			</tr>
  		</table>
  		<form action="/private/statistic" method="post">	
  			<h2>Player's statistics</h2>
    		<select name="player-id" id="player-id" style="width: 150px" onchange="submit()">
    			<option value="" >Choose a player</option>
    			<c:forEach var="player" items="${players}">
    				<option value="${player.id}" >${player.name}</option>
    			</c:forEach>
    		</select>
  		</form>
  		<c:if test="${not empty playerstat}">
  			<table border="1">
  				<tr>
  					<th></th>
  					<th><c:out value="${playerstat.player}" /></th>
  				</tr>
  				<tr>
  					<td>Tournaments</td>
  					<td><c:out value="${playerstat.numberOfTournaments}" /></td>
  				</tr>
  				<tr>
  					<td>Victories</td>
  					<td><c:out value="${playerstat.numberOfVictories}" /></td>
  				</tr>
  				<tr>
  					<td>Heads up</td>
  					<td><c:out value="${playerstat.numberOfHeadsUp}" /></td>
  				</tr>
  				<tr>
  					<td>Defeat</td>
  					<td><c:out value="${playerstat.numberOfDefeat}" /></td>
  				</tr>
  				<tr>
  					<td>Points</td>
  					<td><c:out value="${playerstat.numberOfPoints}" /></td>
  				</tr>
  				<tr>
  					<td>Points / tournament</td>
  					<td><c:out value="${playerstat.averageNumberOfPoints}" /></td>
  				</tr>
  			</table>
  		</c:if>
  		<p><a href="/public/menu">Main menu</a></p>
	</body>
</html>